

#ifndef __WORK_INSTANCE_H
#define __WORK_INSTANCE_H

#include "Actor.h"
#include "../db/KeyDB.h"
#include "../db/NetworkDB.h"
#include "../ssh/SSHClient.h"
#include "../net/BrokerMessage.h"

/** A wrapping class for the work instance actor type. Collects
 * methods involving actors. */
class WorkInstance : public Actor
{
   public:
      WorkInstance(AllDBs *idbs, const char *iname, const char *iowner);
      ~WorkInstance();
      char *getUpdatedClusterList(const char *clusters);
      static int instantiateWork(BrokerMessage &msgin, AllDBs *dbs, apr_pool_t *t_mp);
      char *getWorkDirectory(SSHClient &tclient, const char *workdir);
      char *makeWorkDirectory(SSHClient &tclient, const char *workdir);
      int tryStartingWork(BrokerMessage &msgin, apr_pool_t *t_mp, int i);
      int remoteKeyCopy(SSHClient &sshcli, const char *remotekeyfilename, const char *keyname, Key::keypurposetype keytype, apr_pool_t *t_mp);
      int scheduleWork(SSHClient &sshcli, const char *clustername, apr_pool_t *t_mp, int i, const char *secretpass);
   private:
      /** A structure containing pointers to all the databases. */
      AllDBs *dbs;
      /** The name of this work instance. */
      char *work_instance_id;
      /** The copied owner of this instance. */
      char *copied_owner;
      /** Does this work instance exist? (has it been created?) */
      int existing;
      /** Is the work instance invalid? (and possibly need to be
       * destroyed?) */
      int invalid;
};

#endif
